package com.easyjop.Controller;

import com.easyjop.annotation.GlobalInterceptor;
import com.easyjop.entity.enums.PermissionCodeEnum;
import com.easyjop.entity.query.ChapterQuery;
import com.easyjop.entity.vo.ResponseVO;
import com.easyjop.service.ChapterService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/chapter")
public class ChapterController extends ABaseController{
    @Resource
    private ChapterService chapterService;

    /**
     * 根据条件分页查询
     */
    @RequestMapping("/loadAllChapter")
    @GlobalInterceptor(permissionCode = PermissionCodeEnum.CATEOGRY_LIST)
    public ResponseVO loadDataList(ChapterQuery query) {
        return getSuccessResponseVO(chapterService.findListByPage(query));
    }
    @RequestMapping("/loadAllChapter4Select")
    @GlobalInterceptor
    public ResponseVO loadAllChapter(Integer categoryId) {
        return getSuccessResponseVO(chapterService.loadAllChapterByType(categoryId));
    }
}
